<template>
  <a-drawer v-model:visible="visible" title="试验工作量详情" :width="width >= 600 ? 600 : '100%'" :footer="false">
    <a-descriptions :column="2" size="large" class="general-description">
      <a-descriptions-item label="ID">{{ dataDetail?.id }}</a-descriptions-item>
      <a-descriptions-item label="开始时间">{{ dataDetail?.startTime }}</a-descriptions-item>
      <a-descriptions-item label="结束时间">{{ dataDetail?.endTime }}</a-descriptions-item>
      <a-descriptions-item label="试验时数">{{ dataDetail?.testHour }}</a-descriptions-item>
      <a-descriptions-item label="加班时数">{{ dataDetail?.overtimeHour }}</a-descriptions-item>
      <a-descriptions-item label="登记项目">{{ dataDetail?.registerStatus }}</a-descriptions-item>
      <a-descriptions-item label="试验情况简述">{{ dataDetail?.testDescription }}</a-descriptions-item>
      <a-descriptions-item label="发动机是否故障">{{ dataDetail?.isFault }}</a-descriptions-item>
      <a-descriptions-item label="故障描述">{{ dataDetail?.faultDescription }}</a-descriptions-item>
      <a-descriptions-item label="试验名称">{{ dataDetail?.name }}</a-descriptions-item>
      <a-descriptions-item label="试验任务ID">{{ dataDetail?.taskId }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUser }}</a-descriptions-item>
      <a-descriptions-item label="创建人">{{ dataDetail?.createUserString }}</a-descriptions-item>
      <a-descriptions-item label="创建时间">{{ dataDetail?.createTime }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUser }}</a-descriptions-item>
      <a-descriptions-item label="修改人">{{ dataDetail?.updateUserString }}</a-descriptions-item>
      <a-descriptions-item label="修改时间">{{ dataDetail?.updateTime }}</a-descriptions-item>
    </a-descriptions>
  </a-drawer>
</template>

<script setup lang="ts">
import { useWindowSize } from '@vueuse/core'
import { type TestLogDetailResp, getTestLog as getDetail } from '@/apis/task/testLog'

const { width } = useWindowSize()

const dataId = ref('')
const dataDetail = ref<TestLogDetailResp>()
const visible = ref(false)

// 查询详情
const getDataDetail = async () => {
  const { data } = await getDetail(dataId.value)
  dataDetail.value = data
}

// 打开
const onOpen = async (id: string) => {
  dataId.value = id
  await getDataDetail()
  visible.value = true
}

defineExpose({ onOpen })
</script>

<style scoped lang="scss"></style>
